<template>
    <div class="pool-list">
        <div class="move-box">
            <RiskLeftModule
                v-model="inputValueLeft"
                @on-submit="submitInput"
                @on-handleNode="clickNode"
                :placeholders="'编号/名称'"
                :treeData="treeData"
                :leftHeight="'100vh'"
                :currentKey="cutInfo"
                ref="leftTree"
                :defaultExpandedKeys="defaultExpandedKeys"
            >
                <template slot="ltitle">关联方池信息</template>
            </RiskLeftModule>

            <!-- 池信息 -->
            <template v-if="['local-manage', 'local-leader', 'outer', 'local', 'local-custodian'].includes(cutInfo)">
                <RiskRightModule
                    v-model="selectGroupParam.key"
                    :rightPlace="getRightPlace(cutInfo) + '池编码/名称'"
                    :rightHeight="'100vh'"
                    :showQueryIcon="true"
                    @on-keyup="selectGroup"
                >
                    <p slot="rtitle">{{ getRightPlace(cutInfo) + '池信息' }}</p>
                    <span slot="button" class="dict-r-slot">
                        <el-button type="primary" size="mini" @click="selectGroupBtn">查询</el-button>
                    </span>
                    <span slot="button" class="dict-r-slot" v-show="cutInfo != 'local'">
                        <el-button type="primary" size="mini" v-authCode.show="B_0113" @click="addGroup">新增</el-button>
                    </span>
                    <span slot="button" class="dict-r-slot">
                        <el-button type="primary" size="mini" v-authCode.show="B_0144" :disabled="!tableData.length" @click="downLoadGroupFile"
                            >导出</el-button
                        >
                    </span>
                    <span slot="button" class="dict-r-slot">
                        <el-button type="danger" size="mini" v-authCode.show="B_0114" @click="deleteGroup">删除</el-button>
                    </span>
                    <span slot="button" class="dict-r-slot">
                        <el-button size="mini" @click="operateDecord">操作记录</el-button>
                    </span>
                    <slot>
                        <el-table
                            :data="tableData"
                            border
                            size="mini"
                            style="width: 100%"
                            height="79vh"
                            stripe
                            :default-sort="{ prop: 'dtCtDate', order: 'descending' }"
                            @sort-change="changeTableSort"
                            @selection-change="handleSelectionChange"
                            ref="groupTable"
                            v-loading="loading"
                        >
                            <el-table-column type="selection" width="55" size="mini"> </el-table-column>
                            <el-table-column
                                v-for="item in groupColumns"
                                :prop="item.id"
                                :key="item.id"
                                :label="item.content"
                                :min-width="item.minWidth"
                                show-overflow-tooltip
                                align="center"
                                :sortable="item.sortable"
                            >
                                <template slot-scope="scope">
                                    <span v-if="item.type == 'status'">
                                        {{ item.statusKV[scope.row[item.id]] }}
                                    </span>
                                    <span v-else-if="item.type == 'func'">
                                        {{ item.funcBody(scope.row[item.id]) }}
                                    </span>
                                    <span v-else-if="item.type == 'dtCtDate'">
                                        {{ dateFormat(scope.row[item.id]) }} {{ timeFormat(scope.row['dtCtTime']) }}
                                    </span>
                                    <span v-else-if="item.type == 'dtMdDate'"> 
                                        {{ dateFormat(scope.row[item.id]) }} {{ timeFormat(scope.row['dtMdTime']) }}
                                    </span>
                                    <span v-else>
                                        {{
                                            scope.row[item.id] === 0 || (scope.row[item.id] && (scope.row[item.id] + '').trim())
                                                ? scope.row[item.id]
                                                : '--'
                                        }}
                                    </span>
                                </template>
                            </el-table-column>
                            <el-table-column label="操作" width="160" align="center">
                                <template slot-scope="scope">
                                    <RiskIconButton
                                        type="primary"
                                        icon="el-icon-edit"
                                        v-authCode="B_0115"
                                        :topTitle="'编辑' + getRightPlace(cutInfo) + '池'"
                                        :disabled="cutInfo === 'outer'"
                                        @on-click="editGroupRow(scope.row)"
                                    ></RiskIconButton>
                                    <RiskIconButton
                                        type="danger"
                                        icon="el-icon-delete"
                                        v-authCode="B_0114"
                                        :topTitle="'删除' + getRightPlace(cutInfo) + '池'"
                                        :disabled="cutInfo === 'outer'"
                                        @on-click="deleteGroupRow(scope.row)"
                                    ></RiskIconButton>
                                    <RiskIconButton
                                        type="primary"
                                        icon="el-icon-tickets"
                                        :topTitle="'记录' + getRightPlace(cutInfo) + '池'"
                                        :disabled="cutInfo === 'outer'"
                                        @on-click="remeberGroupRow(scope.row)"
                                    ></RiskIconButton>
                                </template>
                            </el-table-column>
                        </el-table>
                        <div class="block">
                            <RiskPagination :paging="groupPage" @page-change="groupPageChange"></RiskPagination>
                        </div>
                    </slot>
                </RiskRightModule>

                <!-- 新增管理人池 -->
                <yh-dialog
                    :title="groupDialog.title"
                    :visible="groupDialog.visible && (cutInfo == 'local-manage' || AUGroupParam.issueGroupCategory == '2')"
                    width="400px"
                    drag
                    :close-on-click-modal="false"
                    :close-on-press-escape="false"
                    @close="closeGroup"
                >
                    <el-form label-width="140px" size="mini" :rules="groupRules" ref="AUGroupManageParam" :model="AUGroupParam">
                        <el-form-item label="管理人池名称" prop="isGrName">
                            <el-input style="width: 220px" v-model.trim="AUGroupParam.isGrName"></el-input>
                            <!-- @change="onSetIsGroup($event, 'isGrName', '管理人池')" -->
                        </el-form-item>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button size="mini" @click="groupDialogCancel"> 取 消 </el-button>
                        <el-button size="mini" type="primary" @click="groupDialogConfirm"> 确 定 </el-button>
                    </div>
                </yh-dialog>

                <!-- 新增托管人池 -->
                <yh-dialog
                    :title="groupDialog.title"
                    :visible="groupDialog.visible && (cutInfo == 'local-custodian' || AUGroupParam.issueGroupCategory == '1')"
                    width="400px"
                    drag
                    :close-on-click-modal="false"
                    :close-on-press-escape="false"
                    @close="closeGroup"
                >
                    <el-form label-width="140px" size="mini" :rules="groupRules" ref="AUGroupCustodianParam" :model="AUGroupParam">
                        <el-form-item label="关联托管人" prop="localCustodian">
                            <el-select
                                style="width: 220px"
                                v-model.trim="AUGroupParam.localCustodian"
                                @change="localCustodianChange"
                                filterable
                                clearable
                                remote
                                :remote-method="getCustodianPoolList"
                                @clear="getCustodianPoolList('')"
                                @visible-change="handleCustodianPoolVisibleChange"
                                :loading="selectLoading"
                                size="mini"
                                :disabled="groupDialog.action == '2'"
                            >
                                <el-option
                                    v-for="item in custodianPoolList"
                                    :key="item.dictKey"
                                    :value="item.dictKey"
                                    :label="item.dictKey + ' ' + item.dictKeyName"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="托管人池名称" prop="isGrName">
                            <el-input style="width: 220px" v-model.trim="AUGroupParam.isGrName"></el-input>
                            <!-- @change="onSetIsGroup($event, 'isGrName', '托管人池')" -->
                        </el-form-item>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button size="mini" @click="groupDialogCancel"> 取 消 </el-button>
                        <el-button size="mini" type="primary" @click="groupDialogConfirm"> 确 定 </el-button>
                    </div>
                </yh-dialog>

                <!-- 新增董监高池 -->
                <yh-dialog
                    :title="groupDialog.title"
                    :visible="groupDialog.visible && (cutInfo == 'local-leader' || AUGroupParam.issueGroupCategory == '3')"
                    width="400px"
                    drag
                    :close-on-click-modal="false"
                    :close-on-press-escape="false"
                    @close="closeGroup"
                >
                    <el-form label-width="140px" size="mini" :rules="groupRules" ref="AUGroupLeaderParam" :model="AUGroupParam">
                        <el-form-item label="董监高池名称" prop="isGrName">
                            <el-input style="width: 220px" v-model.trim="AUGroupParam.isGrName"></el-input>
                            <!-- @change="onSetIsGroup($event, 'isGrName', '董监高池')" -->
                        </el-form-item>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button size="mini" @click="groupDialogCancel"> 取 消 </el-button>
                        <el-button size="mini" type="primary" @click="groupDialogConfirm"> 确 定 </el-button>
                    </div>
                </yh-dialog>

                <!-- 高级查询-池 -->
                <yh-dialog
                    :title="selectGroupDialog.title"
                    :visible.sync="selectGroupDialog.visible"
                    width="400px"
                    drag
                    :close-on-click-modal="false"
                    :close-on-press-escape="false"
                    v-if="selectGroupDialog.visible"
                >
                    <el-form label-width="140px" size="mini" :model="selectGroupParam" ref="groupForm">
                        <el-form-item label="关联方池编号" prop="groupCode">
                            <el-select v-model="selectGroupParam.groupCode" clearable>
                                <el-option
                                    v-for="item in getGroupSelectCodes()"
                                    :key="item.isGrCode"
                                    :value="item.isGrCode"
                                    :label="item.isGrCode + ' ' + item.isGrName"
                                ></el-option>
                            </el-select>
                            <!-- <el-input style="width: 220px" v-model.trim="selectGroupParam.groupCode"></el-input> -->
                        </el-form-item>
                        <el-form-item label="关联方池名称" prop="groupName">
                            <el-input style="width: 220px" v-model.trim="selectGroupParam.groupName"></el-input>
                        </el-form-item>
                        <el-form-item label="关联类型" prop="issueGroupCategory">
                            <el-select v-model="selectGroupParam.issueGroupCategory" clearable :disabled="cutInfo != 'local'">
                                <el-option
                                    v-for="item in relationOptions"
                                    :key="item.dictKey"
                                    :value="item.dictKey"
                                    :label="item.dictKeyName"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="创建者" prop="createUser">
                            <el-select v-model="selectGroupParam.createUser" filterable clearable>
                                <el-option
                                    v-for="item in orderUsers"
                                    :key="item.dictKey"
                                    :value="item.dictKey"
                                    :label="item.dictKey + ' ' + item.dictKeyName"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="状态" prop="status">
                            <el-select v-model="selectGroupParam.status" clearable>
                                <el-option
                                    v-for="item in statusOptions"
                                    :key="item.dictKey"
                                    :value="item.dictKey"
                                    :label="item.dictKeyName"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                    <div slot="footer" class="dialog-footer">
                        <el-button size="mini" @click="selectGroupDialog.visible = false"> 取 消 </el-button>
                        <el-button size="mini" type="primary" @click="selectGroupDialogConfirm(1)"> 确 定 </el-button>
                    </div>
                </yh-dialog>
            </template>

            <!-- 明细 -->
            <template v-else>
                <RiskRightModule
                    v-model="selectDetailParam.key"
                    :rightPlace="'机构编号/名称'"
                    :rightHeight="'100vh'"
                    :showQueryIcon="true"
                    @on-keyup="selectDetail"
                >
                    <p slot="rtitle">{{ getDetailRightPlace(currentData.issueGroupCategory) + '明细信息' }}</p>
                    <span slot="button" class="dict-r-slot">
                        <el-button type="primary" size="mini" @click="selectDetailBtn">查询</el-button>
                    </span>
                    <span slot="button" class="dict-r-slot">
                        <el-button
                            type="primary"
                            size="mini"
                            v-authCode.show="B_0116"
                            v-if="this.currentData.issueGroupCategory != '3'"
                            @click="editDetail"
                            >编辑</el-button
                        >
                        <el-button type="primary" size="mini" v-if="this.currentData.issueGroupCategory == '3'" @click="addLeaderDetail"
                            >新增</el-button
                        >
                    </span>

                    <span slot="button" class="dict-r-slot">
                        <el-button type="primary" size="mini" v-authCode.show="B_0145" :disabled="!tableData.length" @click="loadoutDetail"
                            >导出</el-button
                        >
                    </span>
                    <span slot="button" class="dict-r-slot">
                        <el-button type="primary" size="mini" v-authCode.show="B_0147" @click="loadinDetail">导入</el-button>
                    </span>
                    <span slot="button" class="dict-r-slot">
                        <el-button type="danger" size="mini" v-authCode.show="B_0117" @click="deleteDetail">删除</el-button>
                        <!-- v-show="this.currentData.sourceType === '1'" -->
                    </span>
                    <span slot="button" class="dict-r-slot">
                        <el-button size="mini" @click="operateDecord">操作记录</el-button>
                    </span>
                    <slot>
                        <el-table
                            :data="tableData"
                            border
                            size="mini"
                            style="width: 100%"
                            height="79vh"
                            stripe
                            @selection-change="handleSelectionDetailChange"
                            v-loading="loading"
                            @sort-change="changeTableSort2"
                        >
                            <el-table-column type="selection" width="55" size="mini" align="center"> </el-table-column>
                            <el-table-column
                                v-for="item in currentData.issueGroupCategory == '3' ? leaderDetailColumns : detailColumns"
                                :prop="item.id"
                                :key="item.id"
                                :label="item.content"
                                :min-width="item.minWidth"
                                show-overflow-tooltip
                                align="center"
                                :sortable="item.sortable"
                            >
                                <template slot-scope="scope">
                                    <span v-if="item.type == 'func'">
                                        {{ item.funcBody(scope.row[item.id]) || '--' }}
                                    </span>
                                    <span v-else-if="item.type == 'dtMdDate'"> 
                                        {{ dateFormat(scope.row[item.id]) }} {{ timeFormat(scope.row['dtMdTime']) }}
                                    </span>
                                    <span v-else>
                                        {{
                                            scope.row[item.id] === 0 || (scope.row[item.id] && (scope.row[item.id] + '').trim())
                                                ? scope.row[item.id]
                                                : '--'
                                        }}
                                    </span>
                                </template>
                            </el-table-column>
                            <el-table-column label="操作" width="160" align="center">
                                <template slot-scope="scope">
                                    <RiskIconButton
                                        type="primary"
                                        icon="el-icon-edit"
                                        :topTitle="'编辑' + getDetailRightPlace(currentData.issueGroupCategory) + '池明细'"
                                        v-show="currentData.issueGroupCategory == '3'"
                                        @on-click="editLeaderDetail(scope.row)"
                                    ></RiskIconButton>
                                    <RiskIconButton
                                        type="danger"
                                        icon="el-icon-delete"
                                        v-authCode="B_0114"
                                        :topTitle="'删除' + getDetailRightPlace(currentData.issueGroupCategory) + '池明细'"
                                        @on-click="deleteDetailRow(scope.row)"
                                    ></RiskIconButton>
                                </template>
                            </el-table-column>
                        </el-table>
                        <div class="block">
                            <RiskPagination :paging="detailPage" @page-change="detailPageChange"></RiskPagination>
                        </div>
                    </slot>
                </RiskRightModule>
            </template>
        </div>
        <!-- 明细编辑 -->
        <yh-dialog
            :title="editDetailDialog.title"
            :visible.sync="editDetailDialog.visible"
            width="1000px"
            class="editDialog"
            drag
            append-to-body
            :fullscreen="fullscreenIs"
            :close-on-click-modal="false"
            :close-on-press-escape="false"
            :class="fullscreenIs == true ? 'testHeight' : ''"
            :before-close="handleClose"
        >
            <i :class="fullscreenIs == false ? 'el-icon-full-screen' : 'el-icon-crop'" @click="changeScreen"></i>
            <RiskTrantableCompanyPool
                ref="tranTable"
                sort="issueName"
                indexKey="issueCode"
                leftPlaceholder="编号/名称"
                rightPlaceholder="编号/名称"
                :columns="tranColumns"
                :rightTableData="rightTranData"
                :grCode="currentData.id"
                :searchNames="['issueCode', 'issueName']"
                url="/componyPool/issueGroup/allIssue"
                url2="/componyPool/issueGroup/relation/insertIssue"
                :idName="['issueCode', 'issueName']"
                v-if="editDetailDialog.visible"
                style="min-height:430px"
                :fullscreenIs="fullscreenIs"
            />
            <div slot="footer" class="dialog-footer">
                <el-button size="mini" @click="editDetailDialogClosed(true)"> 取 消 </el-button>
                <el-button size="mini" type="primary" @click="editDetailDialogConfirm">确 定 </el-button>
            </div>
        </yh-dialog>

        <!-- 删除 -->
        <yh-dialog
            :title="deleteDialog.title"
            :visible.sync="deleteDialog.visible"
            width="500px"
            drag
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <div class="remove-text">
                <!-- <span v-for="(itme, index) in delPendingData" :key="index"> {{ itme }} , </span> -->
                <p>{{ delPendingData.join(',') }}</p>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button size="mini" @click="deleteDialog.visible = false"> 取 消 </el-button>
                <el-button size="mini" type="primary" @click="deleteDialogConfirm">确 定 </el-button>
            </div>
        </yh-dialog>

        <!-- 明细-编辑董监高 -->
        <yh-dialog
            :title="AULeaderDialog.title"
            :visible.sync="AULeaderDialog.visible"
            width="400px"
            drag
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <el-form label-width="140px" size="mini" :rules="AULeaderParamRules" :model="AULeaderParam" ref="AULeaderParam">
                <el-form-item label="董监高名称" prop="issueName">
                    <el-input style="width: 220px" v-model.trim="AULeaderParam.issueName"></el-input>
                </el-form-item>
                <!-- @change="onSetIsGroup($event, 'isGrName', '董监高')" -->
                <el-form-item label="董监高描述" prop="desc">
                    <el-input style="width: 220px" v-model.trim="AULeaderParam.desc"></el-input>
                </el-form-item>
                <el-form-item label="关系类型" prop="relationDesc">
                    <el-input style="width: 220px" v-model.trim="AULeaderParam.relationDesc"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button size="mini" @click="AULeaderDialogCancel"> 取 消 </el-button>
                <el-button size="mini" type="primary" @click="AULeaderDialogConfirm"> 确 定 </el-button>
            </div>
        </yh-dialog>

        <!-- 高级查询-明细池 -->
        <yh-dialog
            :title="selectDetailDialog.title"
            :visible.sync="selectDetailDialog.visible"
            width="400px"
            drag
            :close-on-click-modal="false"
            :close-on-press-escape="false"
        >
            <el-form label-width="140px" size="mini" ref="detailForm" :model="selectDetailParam">
                <el-form-item :label="currentData.issueGroupCategory == '3' ? '董监高名称' : '机构名称'" prop="issueName">
                    <el-input style="width: 220px" v-model.trim="selectDetailParam.issueName"></el-input>
                </el-form-item>
                <!-- <el-form-item label="机构简称" prop="issueName">
                    <el-input style="width: 220px" v-model.trim="selectDetailParam.issueName"></el-input>
                </el-form-item> -->
                <el-form-item label="董监高描述" v-show="currentData.issueGroupCategory == '3'" prop="desc">
                    <el-input style="width: 220px" v-model.trim="selectDetailParam.desc"></el-input>
                </el-form-item>
                <el-form-item label="关系类型" v-show="currentData.issueGroupCategory == '3'" prop="relationDesc">
                    <el-input style="width: 220px" v-model.trim="selectDetailParam.relationDesc"></el-input>
                </el-form-item>
                <el-form-item label="创建者" prop="createUser">
                    <el-select v-model="selectDetailParam.createUser" filterable clearable>
                        <el-option
                            v-for="item in orderUsers"
                            :key="item.dictKey"
                            :value="item.dictKey"
                            :label="item.dictKey + ' ' + item.dictKeyName"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="状态" prop="status">
                    <el-select v-model="selectDetailParam.status" clearable>
                        <el-option v-for="item in statusOptions" :key="item.dictKey" :value="item.dictKey" :label="item.dictKeyName"></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button size="mini" @click="selectDetailDialog.visible = false"> 取 消 </el-button>
                <el-button size="mini" type="primary" @click="selectDetailDialogConfirm(1)"> 确 定 </el-button>
            </div>
        </yh-dialog>

        <OperatedRecord
            :operateDecordShow="operateDecordShow"
            :currentData="isSingleRow ? remRecord : currentData"
            @operated-record="operatedRecordReturn"
            v-if="operateDecordShow"
        ></OperatedRecord>

        <LoadIn :dialogVO="loadinDetailDialog" :currentData="currentData" @load-return="loadReturn" v-if="loadinDetailDialog.visible"></LoadIn>
    </div>
</template>

<script lang="ts">
import { Component, Vue, Watch } from 'vue-property-decorator';

import RiskLeftModule from '@/common/components/risk-left-module.vue';
import RiskRightModule from '@/common/components/risk-right-module.vue';
import RiskIconButton from '@/common/components/risk-icon-button.vue';
import { dateFormat, formatter, formatterDate, formatterNumber, formatterTime, getCurrentPageData, timeFormat } from '@/utils/tools';
import XEUtils from 'xe-utils';
import { DialogVO } from '@yhfin/biz';
import Dict from './dict/index';
import { downLoadFile } from '@/utils/request';
import RiskTrantableCompanyPool from '@/common/components/risk-trantable-company-pool.vue';
import { addLeaderIssue, getInstructionUser, getIssueInfoByGroupCode, getRelationAll, queryGroupInfo, queryGroupIssueInfo } from './api/related-mng';
import OperatedRecord from './related-mng/operated-record.vue';
import RiskPagination from '@/common/components/risk-pagination.vue';
import LoadIn from './related-mng/load-in.vue';

export interface pages {
    total?: number;
    pageSize?: number;
    currentPage?: number;
}

@Component({
    name: 'RelatedMng',
    components: {
        RiskLeftModule,
        RiskRightModule,
        RiskIconButton,
        RiskTrantableCompanyPool,
        OperatedRecord,
        RiskPagination,
        LoadIn,
    },
})
export default class RelatedMng extends Vue {
    formatterDate = formatterDate;
    formatterTime = formatterTime;
    formatter = formatter;
    formatterNumber = formatterNumber;
    dateFormat = dateFormat;
    timeFormat = timeFormat;

    private inputValueLeft: string = '';
    // isSelecting: boolean = false; // 正在查询中

    private localManagePool: any[] = []; // 本地公司池
    private localCustodianPool: any[] = []; // 本地托管池
    private localLeaderPool: any[] = [];

    private outsideList: any[] = [];
    selectGroupDialog: DialogVO = new DialogVO(); // 高级查询
    selectDetailDialog: DialogVO = new DialogVO(); // 高级明细查询
    AULeaderDialog: DialogVO = new DialogVO(); // 董监高明细弹框
    private groupDialog: DialogVO = new DialogVO(); // 公司池新增弹框
    custodianPoolDialog: DialogVO = new DialogVO(); // 托管人新增弹框

    private deleteDialog: DialogVO = new DialogVO();
    private editDetailDialog: DialogVO = new DialogVO(); // 明细编辑
    private loadinDetailDialog: DialogVO = new DialogVO();

    loading: boolean = false; // 表格加载中
    private defaultExpandedKeys: any[] = ['local', 'local-manage', 'local-custodian', 'local-leader'];

    private tranColumns: any[] = [
        {
            label: '编号',
            prop: 'issueCode',
            width: 80,
        },
        {
            label: '名称',
            prop: 'issueName',
            width: 165,
        },
    ];
    private rightTranData: any[] = []; // 穿梭框右侧数据

    custodianPoolList: any[] = []; // 托管人池数据

    selectLoading: boolean = false; // 下拉多选框加载

    private AUGroupParam: any = {}; // AU池

    statusOptions = [
        { dictKey: '1', dictKeyName: '正常' },
        { dictKey: '0', dictKeyName: '已删除' },
    ];

    relationOptions = [
        { dictKey: '2', dictKeyName: '管理人池' },
        { dictKey: '1', dictKeyName: '托管人池' },
        { dictKey: '3', dictKeyName: '董监高池' },
    ];

    selectGroupParam: any = {
        createUser: '',
        groupCode: '',
        groupName: '',
        issueGroupCategory: '',
        status: '',
        key: 'D_DT_CT_DATE DESC',
        sort: '',
    };

    selectDetailParam: any = {
        createUser: '',
        issueName: '',
        status: '',
        desc: '',
        relationDesc: '',
        key: '',
        sort: '',
    };

    operateDecordShow: boolean = false; // 操作记录弹框显示值
    // loadInShow: boolean = false; // 导入弹框显示值
    private groupPage: pages = {
        currentPage: 1,
        pageSize: 50,
        total: 0,
    };

    private detailPage: pages = {
        currentPage: 1,
        pageSize: 50,
        total: 0,
    };

    // private loadPage: pages = {
    //     currentPage: 1,
    //     pageSize: 50,
    //     total: 0,
    // };

    groupColumns = [
        { id: 'isGrCode', content: '关联方池编号', sortable: true },
        { id: 'isGrName', content: '关联方池名称', sortable: false },
        {
            id: 'issueGroupCategory',
            content: '关联类型',
            type: 'status',
            statusKV: {
                '1': '托管人池',
                '2': '管理人池',
                '3': '董监高池',
            },
            sortable: true,
        },
        { id: 'dtCtDate', content: '创建日期', sortable: true, type: 'dtCtDate', funcBody: value => dateFormat(value) },
        // { id: 'dtCtTime', content: '创建时间', sortable: false, type: 'func', funcBody: value => timeFormat(value) },
        { id: 'dtCtUser', content: '创建者', sortable: true },
    ];

    detailColumns = [
        { id: 'issueName', content: '机构名称' },
        { id: 'issueNameSt', content: '机构简称' },
        { id: 'dtMdDate', content: '添加日期', sortable: true, type: 'dtMdDate', funcBody: value => dateFormat(value) },
        // { id: 'dtMdTime', content: '添加时间', type: 'func', funcBody: value => timeFormat(value) },
        { id: 'dtMdUser', content: '添加者' },
    ];

    leaderDetailColumns = [
        { id: 'issueName', content: '董监高名称' },
        { id: 'desc', content: '董监高描述' },
        {
            id: 'relationDesc',
            content: '关系类型',
        },
        { id: 'dtMdDate', content: '添加日期', sortable: true, type: 'dtMdDate', funcBody: value => dateFormat(value) },
        { id: 'dtMdUser', content: '添加者' },
    ];

    private treeData: any[] = [
        {
            id: 'local',
            label: '本地',
            children: [
                { id: 'local-manage', label: '管理人池', children: this.localManagePool, issueGroupCategory: '2' },
                { id: 'local-custodian', label: '托管人池', children: this.localCustodianPool, issueGroupCategory: '1' },
                { id: 'local-leader', label: '董监高池', children: this.localLeaderPool, issueGroupCategory: '3' },
            ],
        },
    ]; // 树形结构数据

    private cutInfo: string = 'local';

    private currentData: any = {}; // 左侧树点击行

    remRecord: any = {}; // 当前记录数据信息

    isSingleRow: boolean = false;

    private tableData: any[] = []; // 显示数据

    private tableDataList: any[] = []; // 表格所有数据

    // private tableDataSearched: any[] = []; // 搜索表格数据

    private hasSelectedData: any[] = []; // 已勾选数据

    private delPendingData: any[] = []; // 待删除数据

    private fullscreenIs: boolean = false;

    Dict: any = new Dict();

    orderUsers: any[] = []; // 操作人

    // 董监高明细参数
    AULeaderParam = {
        desc: '',
        issueName: '',
        relationDesc: '',
    };

    // 池查询参数
    groupQueryParam = {
        createUser: '',
        groupCode: '',
        groupName: '',
        issueGroupCategory: '2',
        status: '',
    };

    // 排序字段
    sortableObj = {
        dtCtDate: 'CONCAT(D_DT_CT_DATE,D_DT_CT_TIME)',
        dtMdDate: 'CONCAT(D_DT_MD_DATE,D_DT_MD_TIME)',
        // dtCtTime: 'D_DT_CT_TIME',
        dtCtUser: 'C_DT_CT_USER',
        isGrCode: 'C_IS_GR_CODE',
        isGrName: 'C_IS_GR_NAME',
        issueGroupCategory: 'C_IS_GR_CATEGORY',
    };
    // sortProp: string = 'dtCtDate'; // 排序字段
    // sortOrder: string = 'descending'; // 排序方式

    mounted() {
        // this.$axios
        //     .post('/componyPool/issueGroup/relation/queryGroupInfo', this.groupQueryParam)
        //     .then(res => {
        //         console.log(res);
        //     })
        //     .catch(err => {
        //         console.log(err);
        //     });

        this.getTreeInfo(true);

        // this.$axios
        //     .post('/componyPool/issueGroup/insert/isGroup', {
        //         isGrCode: '',
        //         isGrName: 'djg池2',
        //         issueGroupCategory: '3',
        //     })
        //     .then(() => {
        //         this.yh_message_success('新增成功');
        //     });

        this.getDict();
    }

    getDict() {
        // 下达人下拉列表
        getInstructionUser().then((res: any) => {
            this.orderUsers = res;
        });
    }

    getRightPlace(param: string) {
        let retValue = '';
        if (param == 'local-custodian') {
            retValue = '托管人';
        } else if (param == 'local-manage') {
            retValue = '管理人';
        } else if (param == 'local-leader') {
            retValue = '董监高';
        }
        return retValue;
    }

    getDetailRightPlace(param: string) {
        let retValue = '';
        if (param == '1') {
            retValue = '托管人';
        } else if (param == '2') {
            retValue = '管理人';
        } else if (param == '3') {
            retValue = '董监高';
        }
        return retValue;
    }

    // 改变窗口大小
    private changeScreen(): void {
        this.fullscreenIs = !this.fullscreenIs;
    }

    // 池信息
    private getTreeInfo(includeClick = false): void {
        getRelationAll().then((res: any) => {
            this.localManagePool = [];
            this.localCustodianPool = [];
            this.localLeaderPool = [];

            for (let item of res) {
                if (item.issueGroupCategory === '2') {
                    this.localManagePool.push({ label: item.isGrCode + '-' + item.isGrName, id: item.isGrCode, ...item });
                } else if (item.issueGroupCategory === '1') {
                    this.localCustodianPool.push({ label: item.isGrCode + '-' + item.isGrName, id: item.isGrCode, ...item });
                } else if (item.issueGroupCategory === '3') {
                    this.localLeaderPool.push({ label: item.isGrCode + '-' + item.isGrName, id: item.isGrCode, ...item });
                }
                // 外部暂未处理
            }

            this.treeData[0].children[0].children = this.localManagePool;
            this.treeData[0].children[1].children = this.localCustodianPool;
            this.treeData[0].children[2].children = this.localLeaderPool;

            includeClick && this.clickNode(this.currentData);
        });
    }

    // 关联托管人改变
    localCustodianChange(value) {
        this.AUGroupParam.isGrName = this.custodianPoolList.find(item => item.dictKey == value).dictKeyName;
    }

    // 分组分页切换(前端分页)
    private groupPageChange(): void {
        this.selectGroupDialogConfirm();
        // val && (this.groupPage.currentPage = val);
        // let data = this.isSelecting ? this.tableDataSearched : this.tableDataList;
        // this.groupPage.total = data.length;
        // this.tableData = getCurrentPageData(data, this.groupPage.currentPage, this.groupPage.pageSize);
    }

    // 明细分页(前端分页)
    private detailPageChange(): void {
        this.selectDetailDialogConfirm();
        // val && (this.detailPage.currentPage = val);
        // let data = this.isSelecting ? this.tableDataSearched : this.tableDataList;
        // this.detailPage.total = data.length;
        // this.tableData = getCurrentPageData(data, this.detailPage.currentPage, this.detailPage.pageSize);
    }

    // 导入数据分页
    // private loadPageChange(val: number): void {
    // this.loadPage.total = this.putTableDataList.length;
    // this.loadPage.currentPage = val;
    // this.putTableData = getCurrentPageData(this.putTableDataList, this.loadPage.currentPage, this.loadPage.pageSize);
    // }

    /* ***************************公共方法区域start*********************************** */
    groupRules = {
        isGrName: [
            { required: true, message: '池名称不可为空', trigger: 'blur' },
            { max: 30, message: '长度不得大于30个字符', trigger: 'blur' },
        ],
        localCustodian: [{ required: true, message: '关联托管人不可为空', trigger: 'blur' }],
    };

    // 节点点击
    private clickNode(data: any): void {
        this.currentData = data || {};
        this.cutInfo = data.id || 'local';
        this.selectGroupParam.sort = '';
        // this.isSelecting = false;

        if (['local-manage', 'local-custodian', 'local-leader', 'outer', 'local'].includes(this.cutInfo)) {
            this.$refs.groupForm && (this.$refs.groupForm as any).resetFields();
            this.selectGroupParam.key = '';
            this.selectGroupParam.sort = 'D_DT_CT_DATE DESC';
            // this.sortProp = 'dtCtDate';
            // this.sortOrder = 'descending';
            // console.log((this.$refs.groupTable as any).sort);
            this.$nextTick(() => {
                this.$refs.groupTable && (this.$refs.groupTable as any).sort('dtCtDate', 'descending');
            });
            this.selectGroupParam.issueGroupCategory = this.currentData.issueGroupCategory || '';
            this.selectGroupDialogConfirm(1);
        } else {
            // 明细节点
            this.selectDetailDialogConfirm(1);
            this.$refs.detailForm && (this.$refs.detailForm as any).resetFields();
            return;
        }
    }

    // 池查询(内含分页)
    private selectGroup(): void {
        this.selectGroupDialogConfirm(1);
        /** this.isSelecting = true;
        this.tableDataSearched = this.handleFilter(this.tableDataList, this.inputValueRight, 'isGrCode', 'isGrName');
        this.groupPageChange(1);  */
    }

    getGroupSelectCodes() {
        let data = [];
        if (this.cutInfo == 'local') {
            data = this.localManagePool.concat(this.localCustodianPool).concat(this.localLeaderPool);
        } else if (this.cutInfo == 'local-manage') {
            data = this.localManagePool;
        } else if (this.cutInfo == 'local-custodian') {
            data = this.localCustodianPool;
        } else if (this.cutInfo == 'local-leader') {
            data = this.localLeaderPool;
        }
        console.log(data, 'data');
        return data;
    }

    // 池查询(按钮)
    selectGroupBtn() {
        this.selectGroupDialog = this.selectGroupDialog.getAddDialog('高级查询');
    }

    // '确认'池查询(按钮)
    selectGroupDialogConfirm(curPage?: number) {
        this.loading = true;
        curPage && (this.groupPage.currentPage = 1);
        queryGroupInfo({
            ...this.selectGroupParam,
            paging: {
                currentPage: this.groupPage.currentPage,
                pageSize: this.groupPage.pageSize,
            },
        })
            .then((res: any) => {
                // this.isSelecting = true;
                this.tableData = res.list;
                this.groupPage.total = res.total;
                // this.groupPageChange(1);

                // if (this.selectGroupParam.issueGroupCategory) {
                //     let name = {
                //         '1': 'local-custodian',
                //         '2': 'local-manage',
                //         '3': 'local-leader',
                //     }[this.selectGroupParam.issueGroupCategory];
                //     let re = this.$refs.leftTree && ((this.$refs.leftTree as any).$refs.tree as any);
                //     re && re.setCurrentKey(name);
                // }
                this.loading = false;
                this.selectGroupDialog.visible = false;
            })
            .catch(() => {
                this.loading = false;
                this.selectGroupDialog.visible = false;
            });
    }

    // 池新增
    private async addGroup() {
        if (this.cutInfo == 'local-custodian') {
            await this.getCustodianPoolList('');
            this.AUGroupParam = {
                isGrCode: '',
                isGrName: '',
                localCustodian: '',
                issueGroupCategory: '1',
            };
            this.groupDialog = this.groupDialog.getAddDialog('新增托管人池');
        } else if (this.cutInfo == 'local-manage') {
            this.AUGroupParam = {
                isGrName: '',
                issueGroupCategory: '2',
            };
            this.groupDialog = this.groupDialog.getAddDialog('新增管理人池');
        } else if (this.cutInfo == 'local-leader') {
            this.AUGroupParam = {
                isGrName: '',
                issueGroupCategory: '3',
            };
            this.groupDialog = this.groupDialog.getAddDialog('新增董监高池');
        }
    }

    // 关闭池新增
    closeGroup() {
        this.groupDialog.visible = false;
    }

    // 行编辑池
    private async editGroupRow(row: any) {
        if (row.issueGroupCategory == '1') {
            await this.getCustodianPoolList('');
            this.groupDialog = this.groupDialog.getUpdateDialog('编辑托管人池');
        } else if (row.issueGroupCategory == '2') {
            this.groupDialog = this.groupDialog.getUpdateDialog('编辑管理人池');
        } else if (row.issueGroupCategory == '3') {
            this.groupDialog = this.groupDialog.getUpdateDialog('编辑董监高池');
        }
        this.AUGroupParam = JSON.parse(JSON.stringify(row));
        console.log(row, 'row---');
    }

    // '确认'新增||编辑池
    private async groupDialogConfirm(): Promise<void> {
        // let value = this.AUGroupParam.isGrName;
        // let name = '';
        // if (this.cutInfo == 'local-manage') {
        //     name = '管理人池';
        // } else if (this.cutInfo == 'local-custodian') {
        //     name = '托管人池';
        // } else if (this.cutInfo == 'local-leader') {
        //     name = '董监高池';
        // }

        // if (!value) {
        //     this.yh_message_error(name + '名称不能为空!');
        //     return;
        // } else if (value && value.length > 30) {
        //     this.yh_message_error(name + '名称超出字符长度限制!');
        //     return;
        // }
        let value = this.getRefName();
        let valid = this.validateForm(value);
        if (!valid) return;
        try {
            if (this.groupDialog.action === 1) {
                await this.$axios.post('/componyPool/issueGroup/insert/isGroup', this.AUGroupParam);
                this.yh_message_success('新增成功');
            } else {
                await this.$axios.put('/componyPool/issueGroup/update', this.AUGroupParam);
                this.yh_message_success('编辑成功');
            }
            this.reset('AUGroupManageParam');
        } catch (err) {
            console.log(err, 'err');
        } finally {
            this.getTreeInfo();
            this.selectGroupDialogConfirm();
            this.groupDialog.visible = false;
        }
    }

    // getGroupData() {
    //     let value = this.AUGroupParam.issueGroupCategory
    //     if (this.cutInfo === 'local') {
    //         this.tableDataList = this.localManagePool.concat(this.localCustodianPool).concat(this.localLeaderPool);
    //     } else if (this.cutInfo == 'outer') {
    //         this.tableDataList = this.outsideList;
    //     } else if (this.cutInfo == 'local-manage') {
    //         this.tableDataList = this.localManagePool;
    //     } else if (this.cutInfo == 'local-custodian') {
    //         this.tableDataList = this.localCustodianPool;
    //     } else if (this.cutInfo == 'local-leader') {
    //         this.tableDataList = this.localLeaderPool;
    //     }
    // }

    groupDialogCancel() {
        let value = this.getRefName();
        this.reset(value);
        this.groupDialog.visible = false;
    }

    getRefName() {
        let name = '';
        if (this.cutInfo == 'local-manage' || this.AUGroupParam.issueGroupCategory == '2') {
            name = 'AUGroupManageParam';
        } else if (this.cutInfo == 'local-custodian' || this.AUGroupParam.issueGroupCategory == '1') {
            name = 'AUGroupCustodianParam';
        } else if (this.cutInfo == 'local-leader' || this.AUGroupParam.issueGroupCategory == '3') {
            name = 'AUGroupLeaderParam';
        }
        return name;
    }

    // 池删除
    private deleteGroup(): void {
        if (this.hasSelectedData.length < 1) {
            this.yh_message_warn('未选择删除项');
        } else {
            this.delPendingData = this.hasSelectedData;
            this.deleteDialog = this.deleteDialog.getDeleteDialog('确定删除公司池?');
        }
    }

    // '确认'删除
    private deleteDialogConfirm(): void {
        if (['local-manage', 'local-custodian', 'local-leader', 'outer', 'local'].includes(this.cutInfo)) {
            // /componyPool/issueGroup/delete
            this.$axios({
                url: '/componyPool/issueGroup/relation/delete',
                method: 'DELETE',
                data: this.delPendingData,
            }).then(res => {
                this.yh_message_success('删除成功');
                this.getTreeInfo();
                this.selectGroupDialogConfirm();
                this.deleteDialog.visible = false;
            });
        } else {
            // /componyPool/issueGroup/delete/issue/
            this.$axios({
                url: '/componyPool/issueGroup/relation/deleteIssue/' + this.currentData.id,
                method: 'DELETE',
                data: this.delPendingData,
            }).then(res => {
                this.yh_message_success('删除成功');
                this.selectDetailDialogConfirm(1);
                this.deleteDialog.visible = false;
            });
        }
        this.hasSelectedData = [];
    }

    // 公司池|| 明细筛选数据
    // private handleFilter(dataSource: any, param: any, code: string, name: string): any {
    //     if (!param || !dataSource) {
    //         return dataSource;
    //     } else {
    //         return dataSource.filter(
    //             (item: any) =>
    //                 (item[name] || '').toUpperCase().includes(param.toUpperCase()) || (item[code] || '').toUpperCase().includes(param.toUpperCase())
    //         );
    //     }
    // }

    // 公司池名称||关联方长度限制
    // private onSetIsGroup(value: string, field: string, name: string) {
    //     if (value) {
    //         value = value.trim();
    //         if (field == 'isGrName' && value.length > 30) {
    //             this.yh_message_error(name + '名称超出字符长度限制!');
    //         } else if (field == 'issueGroupMain' && value.length > 6) {
    //             this.yh_message_error(name + '名称长度超过字符长度限制!');
    //         }
    //     }
    //     return value;
    // }

    // 获取管理人明细数据
    private getDetailInfoAll(id: string): void {
        /**
         getIssueInfoByGroupCode(this.currentData.id)
            .then((res: any) => {
                this.tableDataList = res;
                this.selectDetail();
            })
            .catch(() => {});
        */
    }

    // 明细编辑
    private editDetail(): void {
        this.editDetailDialog = this.editDetailDialog.getAddDialog('编辑' + this.getDetailRightPlace(this.currentData.issueGroupCategory) + '池');
        this.rightTranData = this.tableDataList;
    }

    // 明细编辑'确认'
    private editDetailDialogConfirm(needNotify = true): any {
        let needData = [];
        if (needNotify) {
            this.yh_message_success('编辑成功');
            this.selectDetailDialogConfirm(1);
            this.editDetailDialogClosed();
        } else {
            const changed = (this.$refs.tranTable as any).getChanged();
            // getRightAllData();
            if (changed) {
                // 取消更新的副本，复原数据，只需要更新数据，不用提示
                needData = this.tableDataList.map(item => item.issueCode);
                needData = [...new Set(needData)];
                return new Promise((resolve, reject) => {
                    this.$axios.post('/componyPool/issueGroup/insert/isGroup/issue/' + this.currentData.id, needData).then((res: any) => {
                        resolve(res);
                    });
                });
            } else {
            }
        }
    }

    // 编辑弹框关闭
    async editDetailDialogClosed(needRestore = false) {
        // true为点击取消还原成之前  false为已还原 仅关闭弹窗即可
        if (needRestore) {
            await this.editDetailDialogConfirm(false);
            await (this.editDetailDialog.visible = false);
        } else {
            this.editDetailDialog.visible = false;
        }
    }

    // 弹框关闭前
    private handleClose(done) {
        console.log(done, 'done');
        this.asycHandleClose(done);
    }

    async asycHandleClose(done) {
        let newVar = await this.editDetailDialogConfirm(false);
        await done();
    }

    // 明细查询
    private selectDetail(): void {
        this.selectDetailDialogConfirm(1);
        /** this.isSelecting = true;
        this.tableDataSearched = this.handleFilter(this.tableDataList, this.inputDetailValueRight, 'issueCode', 'issueName');
        this.detailPageChange(1); */
    }

    // 池明细查询(按钮)
    selectDetailBtn() {
        this.selectDetailDialog = this.selectDetailDialog.getAddDialog('高级查询');
    }

    // '确认'池明细(按钮)查询
    async selectDetailDialogConfirm(curPage?: number) {
        this.loading = true;
        curPage && (this.detailPage.currentPage = 1);
        try {
            await queryGroupIssueInfo({
                ...this.selectDetailParam,
                groupCode: this.currentData.isGrCode,
                paging: {
                    currentPage: this.detailPage.currentPage,
                    pageSize: this.detailPage.pageSize,
                },
            }).then((res: any) => {
                // this.isSelecting = true;
                this.tableData = res.list;
                this.detailPage.total = res.total;
                // this.detailPageChange(1);
            });
        } finally {
            this.loading = false;
            this.selectDetailDialog.visible = false;
        }
    }
    // 勾选
    private handleSelectionChange(data: any[]): void {
        this.hasSelectedData = XEUtils.map(data, item => item.isGrCode);
    }

    // 明细勾选
    private handleSelectionDetailChange(data: any[]): void {
        this.hasSelectedData = XEUtils.map(data, item => item.issueCode);
    }

    // 行删除公司池
    private deleteGroupRow(row: any): void {
        console.log(row, 'deleteGroupRow');
        this.delPendingData = [row.isGrCode];
        this.deleteDialog = this.deleteDialog.getDeleteDialog('确定删除公司池？');
    }

    // 删除明细
    private deleteDetail(): void {
        if (this.hasSelectedData.length < 1) {
            this.yh_message_warn('未选择删除项!');
        } else {
            this.delPendingData = this.hasSelectedData;
            this.deleteDialog = this.deleteDialog.getDeleteDialog('确认删除池下发行人？');
        }
    }

    // 明细行删除
    deleteDetailRow(row: any) {
        // deleteIssue(this.currentData.id,row)
        this.delPendingData = [row.issueCode];
        this.deleteDialog = this.deleteDialog.getDeleteDialog('确认删除池下发行人？');
    }

    // 操作记录
    operateDecord() {
        this.isSingleRow = false;
        this.operateDecordShow = true;
    }

    // 行记录
    remeberGroupRow(row: any) {
        this.isSingleRow = true;
        this.remRecord = row;
        this.operateDecordShow = true;
    }

    // 操作记录回调
    operatedRecordReturn() {
        this.operateDecordShow = false;
    }

    // 池导出
    private downLoadGroupFile(): void {
        let type = ['local-manage', 'local-custodian', 'local-leader', 'local'].includes(this.cutInfo) ? '1/' : '2';
        let category = {
            'local-manage': '3',
            'local-custodian': '1',
            'local-leader': '4',
            local: '5',
        }[this.cutInfo];

        let data = this.hasSelectedData;
        if (this.hasSelectedData.length < 1 || !this.hasSelectedData) {
            data = XEUtils.map(this.tableDataList, item => item.isGrCode);
        }
        downLoadFile({
            url: '/componyPool/export/company/pool/' + type + category,
            method: 'post',
            data: data,
        });
    }

    //  导出明细
    private loadoutDetail(): void {
        let data = this.hasSelectedData;
        if (this.hasSelectedData.length < 1 || !this.hasSelectedData) {
            data = XEUtils.map(this.hasSelectedData, item => item.issueCode);
        }
        downLoadFile({
            url: '/componyPool/export/company/' + this.currentData.id,
            method: 'post',
            data: data,
        });
    }

    // 导入明细
    private loadinDetail(): void {
        this.loadinDetailDialog = this.loadinDetailDialog.getAddDialog(
            '导入' + this.getDetailRightPlace(this.currentData.issueGroupCategory) + '池明细信息'
        );
    }

    // 导入回调
    loadReturn(type: string) {
        type == 'confirm' && this.selectDetailDialogConfirm(1);
        this.loadinDetailDialog.visible = false;
    }

    // 左侧搜索
    private submitInput(): void {}

    // 校验
    validateForm(formName) {
        let res;
        (this.$refs[formName] as any).validate(valid => {
            if (!valid) {
                res = false;
                return false;
            } else {
                res = true;
            }
        });
        return res;
    }

    reset(valueName) {
        this.$nextTick(() => {
            // console.log(valueName, this.$refs[valueName]);
            this.$refs[valueName] && (this.$refs[valueName] as any).clearValidate();
        });
    }

    // 排序改变
    private changeTableSort(column): void {
        console.log(column, 'column');
        // this.sortProp = column.prop;
        // this.sortOrder = column.order;
        let sortType = column.order == 'ascending' ? 'ASC' : column.order == 'descending' ? 'DESC' : '';
        if (sortType) {
            this.selectGroupParam.sort = this.sortableObj[column.prop] + ' ' + sortType;
        } else {
            this.selectGroupParam.sort = '';
        }
        this.selectGroupDialogConfirm(1);
    }
    // 排序改变
    private changeTableSort2(column): void {
        // this.sortProp = column.prop;
        // this.sortOrder = column.order;
        let sortType = column.order == 'ascending' ? 'ASC' : column.order == 'descending' ? 'DESC' : '';
        if (sortType) {
            this.selectDetailParam.sort = this.sortableObj[column.prop] + ' ' + sortType;
        } else {
            this.selectDetailParam.sort = '';
        }
        this.selectDetailDialogConfirm(1);
    }

    /* ***************************公共方法区域end*********************************** */

    /* ***************************管理人池区域start*********************************** */

    /* ***************************管理人池区域end*********************************** */

    /* ********************托管人start****************************** */
    // 托管人池字典值
    getCustodianPoolList(e: string) {
        return new Promise((resolve, reject) => {
            this.$axios
                .post('/componyPool/issueGroup/custodianList', {
                    dictKey: e,
                    dictKeyName: e,
                })
                .then((res: any) => {
                    this.custodianPoolList = res || [];
                    resolve(res);
                    this.selectLoading = false;
                })
                .catch(error => {
                    reject(error);
                    this.selectLoading = false;
                });
        });
    }

    async handleCustodianPoolVisibleChange(isShow: boolean) {
        if (!isShow && !this.custodianPoolList.length) {
            await this.getCustodianPoolList('');
        }
    }

    /* ********************托管人end****************************** */

    /* ********************董监高池start****************************** */
    // 校验规则
    AULeaderParamRules = {
        issueName: [
            { required: true, message: '董监高名称不可为空', trigger: 'blur' },
            { max: 30, message: '长度不得大于30个字符', trigger: 'blur' },
        ],
    };
    // 新增董监高明细
    addLeaderDetail() {
        this.AULeaderParam = {
            desc: '',
            issueName: '',
            relationDesc: '',
        };
        this.AULeaderDialog = this.AULeaderDialog.getAddDialog('新增董监高明细');
    }

    // 明细行编辑-董监高
    editLeaderDetail(row: any) {
        let param = JSON.parse(JSON.stringify(row));
        // desc和relationDesc修改时必传
        this.AULeaderParam = {
            desc: '',
            relationDesc: '',
            ...param,
        };
        this.AULeaderDialog = this.AULeaderDialog.getUpdateDialog('修改董监高明细');
    }

    // '确定'新增/修改董监高
    async AULeaderDialogConfirm() {
        console.log(this.AULeaderParam);
        // let value = this.AULeaderParam.issueName;
        // if (!value) {
        //     this.yh_message_error('董监高明细名称不能为空!');
        //     return;
        // } else if (value && value.length > 30) {
        //     this.yh_message_error('董监高明细名称超出字符长度限制!');
        //     return;
        // }
        let valid = this.validateForm('AULeaderParam');
        if (!valid) return;
        try {
            if (this.AULeaderDialog.action == 1) {
                await addLeaderIssue({
                    ...this.AULeaderParam,
                    groupCode: this.currentData.id,
                });
                this.yh_message_success('新增成功');
            } else {
                await addLeaderIssue({
                    ...this.AULeaderParam,
                    groupCode: this.currentData.id,
                });
                this.yh_message_success('修改成功');
            }
            this.clickNode(this.currentData);
        } catch (err) {
            console.log(err, 'err');
        } finally {
            this.AULeaderDialog.visible = false;
        }
    }

    AULeaderDialogCancel() {
        this.reset('AULeaderParam');
        this.AULeaderDialog.visible = false;
    }

    /* ********************董监高池end****************************** */
}
</script>
<style lang="scss" scoped>
.pool-list {
    position: relative;
    height: 100%;
    .dict-r-slot {
        margin-left: 10px;
    }

    & /deep/ .el-dialog .el-dialog__body {
        max-height: 100vh;
    }
}
/deep/ .editDialog .el-dialog {
    margin-top: 10vh !important;
    .el-dialog__body {
        max-height: 90vh !important;
        max-height: 90vh;
        padding: 10px;
    }
}
/deep/ .el-dialog .el-dialog__body {
    max-height: 100vh !important;
}
.el-icon-full-screen,
.el-icon-crop {
    position: absolute;
    top: 13px;
    right: 45px;
    color: white;
    &:hover {
        color: #909399;
    }
}

/deep/ .el-form-item.is-required:not(.is-no-asterisk) > .el-form-item__label:after {
    color: red;
}

/deep/ .el-form-item--mini .el-form-item__error {
    color: red;
}
</style>
